using UniversalAdminSystem.Domian.Core.Interfaces;
using UniversalAdminSystem.Domian.PermissionManagement.Aggregate;
using UniversalAdminSystem.Domian.PermissionManagement.ValueObjects;

namespace UniversalAdminSystem.Domian.PermissionManagement.IRepository;

/// <summary>
/// 权限仓储接口
/// 提供权限数据的持久化操作
/// </summary>
public interface IPermissionRepository : IRepository<Permission>
{
    /// <summary>
    /// 批量添加系统权限
    /// </summary>
    /// <param name="systemPermissions">系统权限集合</param>
    /// <returns>添加操作结果</returns>
    Task AddSystemPermissionsAsync(IEnumerable<Permission> systemPermissions);
    
    /// <summary>
    /// 根据权限ID集合获取权限集合
    /// </summary>
    /// <param name="permissionIds">权限ID集合</param>
    /// <returns>权限集合</returns>
    Task<IEnumerable<Permission>> GetByIdsAsync(IEnumerable<Guid> permissionIds);

    /// <summary>
    /// 根据权限编码获取权限
    /// </summary>
    /// <param name="permissionCode">权限编码</param>
    /// <returns>权限实体，如果不存在则返回null</returns>
    Task<Permission?> GetByCodeAsync(PermissionCode permissionCode);

    /// <summary>
    /// 根据条件查询权限
    /// </summary>
    /// <param name="name">权限名称（可选）</param>
    /// <param name="resource">权限资源（可选）</param>
    /// <param name="action">权限操作类型（可选）</param>
    /// <param name="type">权限类型（可选）</param>
    /// <returns>符合条件的权限集合</returns>
    Task<IEnumerable<Permission>> QueryAsync(
        string? name = null, 
        string? resource = null, 
        int? action = null, 
        PermissionType? type = null
    );

    /// <summary>
    /// 根据权限编码判断权限是否存在
    /// </summary>
    /// <param name="permissionCode">权限编码</param>
    /// <returns>权限是否存在</returns>
    Task<bool> ExistsAsync(PermissionCode permissionCode);
}
